package com.fd.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/student")
public class StudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("StudentServlet.doGet ");
        //在doGet中的resp用来表示向客户端输出的对象,在这个对象中包含一个打印流,可以直接向用户浏览器发送数据
        PrintWriter writer = resp.getWriter();
        writer.println("Welcome to Fd2030");
        writer.println("<h1>  Address is Shen Zhen Bao an </h1>");
        writer.close();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("StudentServlet.doPost");
    }

    @Override
    public void init(ServletConfig config) throws ServletException {
        String name = config.getInitParameter("name");
    }
}
